home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.06 Jun 89 / HyperArrays ƒ / HyperArrays / HyperArrays / card_3517.txt < prev    next >
Encoding:
Text File  |  1989-03-13  |  3.1 KB  |  132 lines

  1. -- card: 3517 from stack: in
  2. -- bmap block id: 3586
  3. -- flags: 0000
  4. -- background id: 2603
  5. -- name: 
  6. ----- HyperTalk script -----
  7. on opencard
  8.   global firsttime
  9.   put 1 into firsttime
  10.   set visible of cd fld "about" to false
  11. end opencard
  12.  
  13.  
  14. -- part 1 (button)
  15. -- low flags: 00
  16. -- high flags: 8004
  17. -- rect: left=386 top=18 right=40 bottom=486
  18. -- title width / last selected line: 0
  19. -- icon id / first selected line: 0 / 0
  20. -- text alignment: 1
  21. -- font id: 0
  22. -- text size: 12
  23. -- style flags: 0
  24. -- line height: 16
  25. -- part name: graph
  26. ----- HyperTalk script -----
  27. on mouseup
  28.   global firsttime
  29.   if firsttime > 1 then cleanup
  30.   drawgraph
  31.   pointsetup
  32.   graphpoints
  33.   put 2 into firsttime
  34.  
  35. end mouseup
  36. on cleanup
  37.   choose lasso tool
  38.   domenu "select"
  39.   domenu "cut picture"
  40.   choose browse tool
  41. end cleanup
  42. on drawgraph
  43.   choose line tool
  44.   drag from 100,200 to 100,305
  45.   domenu "trace edges"
  46.   choose line tool
  47.   drag from 95,300 to 300,300
  48.   domenu "trace edges"
  49.   choose browse tool
  50. end drawgraph
  51. on pointsetup
  52.  
  53.   put 1 into linecount
  54.   repeat 50
  55.     putdata linecount,random(50)
  56.     put linecount + 1 into linecount
  57.   end repeat
  58. end pointsetup
  59.  
  60. on graphpoints
  61.  
  62.   put 1 into horiz
  63.   repeat forever
  64.     if the mouse is down then exit repeat
  65.  
  66.     repeat 50
  67.       getdata horiz
  68.       put the result into vert
  69.       getprevdata horiz
  70.       put the result into vert1
  71.       choose pencil tool
  72.       click at 101+horiz*4,299-(100-vert)
  73.       click at 101+horiz*4,299-(100-vert1)
  74.       put horiz + 1 into horiz
  75.       if horiz > 50 then
  76.         databuff
  77.         pointsetup
  78.         put 1 into horiz
  79.       end if
  80.  
  81.     end repeat
  82.   end repeat
  83.   choose browse tool
  84. end graphpoints
  85.  
  86.  
  87.  
  88. -- part 2 (button)
  89. -- low flags: 00
  90. -- high flags: 8004
  91. -- rect: left=35 top=21 right=43 bottom=144
  92. -- title width / last selected line: 0
  93. -- icon id / first selected line: 0 / 0
  94. -- text alignment: 1
  95. -- font id: 0
  96. -- text size: 12
  97. -- style flags: 0
  98. -- line height: 16
  99. -- part name: about this card
  100. ----- HyperTalk script -----
  101. on mouseUp
  102.   set visible of cd fld "about" to true
  103. end mouseUp
  104.  
  105.  
  106.  
  107. -- part 3 (field)
  108. -- low flags: 01
  109. -- high flags: 0007
  110. -- rect: left=36 top=46 right=192 bottom=473
  111. -- title width / last selected line: 0
  112. -- icon id / first selected line: 0 / 0
  113. -- text alignment: 0
  114. -- font id: 3
  115. -- text size: 12
  116. -- style flags: 0
  117. -- line height: 16
  118. -- part name: about
  119. ----- HyperTalk script -----
  120. on mouseup
  121.   set the visible of me to false
  122. end mouseup
  123.  
  124.  
  125. -- part contents for card part 3
  126. ----- text -----
  127. The Script in the 'Graph' button provides an example of using all four XCMD's:
  128.     -the first XCMD 'PUTDATA' puts a random number between 1 and 50 into the array rsrc in 50 points.
  129.     - the second XCMD 'GetData' retrieves those values
  130. The example script sets up the array and retrieves the data in a sequential fashion but random access is possible.
  131.     -the third XCMD 'DataBuff' sets up a buffer array of 50 points that were just derived so that the script can erase the previous point before it plots a new one - this must be done with a fourth XCMD 'Getpreviousdata' which is identical to 'Getdata' except that it accesses data from the buffer array instead of the working array.
  132.